onEvent('block.right_click', event => {
	//禁用血魔法恶魔领域的仪式 禁用创造板条箱
    //event.block.id == 'bloodmagic:inversion_pillar' || 
	if (event.block.id == 'create:creative_crate' || event.block.id == 'bloodmagic:inversion_pillar') {
		console.log("Please don't do this");
		event.cancel();// 取消该事件
	}else if(event.block.id == 'atum:fertile_soil_path' || event.block.id == 'atum:fertile_soil_tilled' || event.block.id == 'atum:fertile_soil'){
        event.cancel();
    }
});

onEvent('item.right_click', event => {

    // 判断右键使用的物品
    if (event.item.id == 'astralsorcery:wand') {
        event.server.runCommandSilent('/astralsorcery maximize @p');
    }
    else if(event.item.id == 'forbidden_arcanus:pixie')
    {
        event.cancel();
        //console.log(event.item.x + event.item.y + event.item.z)
        //console.log(event.player.x + event.player.y + event.player.z)
        event.server.runCommandSilent(`/summon mythicbotany:alf_pixie ${event.player.x} ${event.player.y + 0.7} ${event.player.z} {ActiveEffects:[{Id:24,Amplifier:5,Duration:600}]}`);
        if (!event.player.isCreativeMode()) {
            event.item.setCount(event.item.getCount() - 1)
        }
       
    }
    else if(event.item.id == 'botania:teru_teru_bozu'){
        event.server.runCommandSilent('/weather clear')
        if (!event.player.isCreativeMode()) {
            event.item.setCount(event.item.getCount() - 1)
        }
    }
});

onEvent('block.break',event =>{
    //console.log(event.block.id);
    if(event.block.id == 'bloodmagic:rawdemoncrystal'){
        givePlayerItem(event,'bloodmagic:growing_doubt',100);
    }else if(event.block.id == 'minecraft:bedrock'){
        givePlayerItem(event,'minecraft:bedrock',100);
    }else if(event.block.id == 'minecraft:end_portal_frame'){
        givePlayerItem(event,'minecraft:end_portal_frame',100);
    }
})


// onEvent('entity.spawned',event =>{
//     console(event.entity);
// });

///astralsorcery maximize @p


//修改神圣土和诅咒土的掉落物
onEvent('block.loot_tables', event => {
    event.addSimpleBlock('mob_grinding_utils:dreadful_dirt', 'kubejs:polluted_dirt');
    event.addSimpleBlock('mob_grinding_utils:delightful_dirt', 'kubejs:polluted_dirt');
    event.addSimpleBlock('atum:fertile_soil_path', 'atum:sand');
    event.addSimpleBlock('atum:fertile_soil_tilled', 'atum:sand');
    event.addSimpleBlock('atum:fertile_soil', 'atum:sand');
    event.addSimpleBlock('atum:deadwood_log', 'kubejs:polluted_dust');
    event.addSimpleBlock('atum:deadwood_planks', 'kubejs:polluted_dust');
    event.addSimpleBlock('atum:palm_planks', 'kubejs:polluted_dust');
    event.addSimpleBlock('atum:palm_fence', 'kubejs:polluted_dust');
    event.addSimpleBlock('atum:palm_stairs', 'kubejs:polluted_dust');
    event.addSimpleBlock('atum:stripped_palm_log', 'kubejs:polluted_dust');
    event.addSimpleBlock('atum:stripped_deadwood_log','kubejs:polluted_dust');
    event.addSimpleBlock('minecraft:bedrock','minecraft:bedrock');
    event.addSimpleBlock('minecraft:end_portal_frame','minecraft:end_portal_frame');
});



function givePlayerItem(event, items, odds) {
    var a = Math.round(Math.random() * 100);
    if (a <= odds) {
        let i = event.block.pos;
        let output_count = 1;
        let output = items;
        //console.log(`summon minecraft:item ${event.block.x} ${event.block.y + 0.7} ${event.block.z} {PickupDelay:10,Motion:[0.0,0.2,0.0],Item:{id:"${output}",Count:${output_count}b}}`);
        event.server.runCommandSilent(`summon minecraft:item ${event.block.x} ${event.block.y + 1.2} ${event.block.z} {PickupDelay:10,Motion:[0.0,0.2,0.0],Item:{id:"${output}",Count:${output_count}b}}`)
        //event.player.give(items);

    }
}

function givePlayerItem_1(event, items, odds,output_count) {
    var a = Math.round(Math.random() * 100);
    if (a <= odds) {
        let i = event.block.pos;
        let output = items;
        //console.log(`summon minecraft:item ${event.block.x} ${event.block.y + 0.7} ${event.block.z} {PickupDelay:10,Motion:[0.0,0.2,0.0],Item:{id:"${output}",Count:${output_count}b}}`);
        event.server.runCommandSilent(`summon minecraft:item ${event.block.x} ${event.block.y + 1.2} ${event.block.z} {PickupDelay:10,Motion:[0.0,0.2,0.0],Item:{id:"${output}",Count:${output_count}}}`)
        //event.player.give(items);

    }
}

